<template>
    <view class="check">
        <phone-input name="Phone" @change="updatePhoneNumber"></phone-input>
        <u-button class="gap-col-top2" @click="handleCheck" type="primary" size="large" :text="$t('check.in')"></u-button>
    </view>
</template>

<script>
import { goBack, showSuccess } from '../../../lib/helper';
import { check } from '../../../lib/service';
export default {
    data() {
        return {
            id: '',
            phone: ''
        };
    },
    onLoad(options) {
        this.id = options.id;
    },
    methods: {
        updatePhoneNumber(value) {
            this.phone = value;
        },
        handleCheck() {
            uni.showLoading();
            check({ houseId: this.id, phone: this.phone }).then((res) => {
                uni.hideLoading();
                showSuccess();
                setTimeout(() => {
                    goBack();
                }, 480);
            });
        }
    }
};
</script>

<style lang="scss" scoped>
.check {
    padding: 0 30px;
}
</style>
